﻿Imports System.Net
Imports Newtonsoft.Json.Linq
Imports System.Text

Module Api
    Public access_token, user_id As String
    Public Async Function VKPost(metod As String, Optional options As String = "") As Task(Of JToken)
        Dim wc As New WebClient
        wc.Encoding = Encoding.UTF8
        wc.Headers.Add(HttpRequestHeader.ContentType, "application/x-www-form-urlencoded")
        Dim r = Await wc.UploadStringTaskAsync("https://api.vk.com/method/" & metod, options & "&access_token=" & access_token)
        Return JObject.Parse(r)("response")
    End Function

    Public Async Function VKGet(url As String) As Task(Of JToken)
        Dim wc As New WebClient
        wc.Encoding = Encoding.UTF8
        Dim r = Await wc.DownloadStringTaskAsync(url)
        Return JObject.Parse(r)
    End Function
End Module
